home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1995-09-07 | 1.9 KB | 79 lines |
- ' Bouncing ball
- ' ~~~~~~~~~~~~~
- ' by Ben Wyatt, bwyatt@paston.co.uk
-
- ' A reasonably accurate bouncing ball
- ' It doesn't roll down hills or anything (yet)
- ' If the ball gets stuck, press the lmb, to er... shake the screen
- ' It's just a test to see if a pinball game would be possible and collisions
- ' would be fast enough :) but for some reason, it's fun to watch :-/
- ' Turbo/AMCAF users can replace the Point/Sqr functions with the faster
- ' equivilants, not that it makes any difference, it's fixed to 1/50 speed
- ' Remove the Wait Vbl and compile it for super sonic speed :-)
-
- Degree
-
- Dim SAN(15),CAN(15)
-
- ' Precalc some stuff
- For N=0 To 15
- SAN(N)=Sin(N*(360/16))*8 : CAN(N)=Cos(N*(360/16))*8
- Next N
-
- Load "Ball.Abk"
- Load Iff Fsel$("Ball_Scr_*","","Select one of the shown files",""),0
- Screen Display 0,128,37,320,256
- YS=0
- Hide On
-
- Hot Spot 1,7,7
-
- Do
-
- Screen Offset 0,0,0
-
- ' Get a position to start in
- Repeat
- X=X Mouse : Y=Y Mouse
- Sprite 0,X,Y,1
- Until Mouse Key>0
-
- X=X Screen(X)*1024 : Y=Y Screen(Y)*1024
- XSP=0 : YSP=0 : ROT=0
-
- Repeat
-
- Add X,XSP
- Add Y,YSP
- Add YSP,100
-
- XSD=XSP : YSD=YSP
- For N=0 To 15
- FP=Point(X/1024+SAN(N),Y/1024+CAN(N))
- If FP>CP
- SPD=Sqr(XSD*XSD+YSD*YSD)/16
- AN=N+8
- If AN>15 : Add AN,-16 : End If
- XSP=SAN(AN)*SPD : YSP=CAN(AN)*SPD
- Add X,XSP : Add Y,YSP
- ' If you want to get really annoyed, unrem the next line :-)
- 'Boom
- End If
- Next N
-
- Sprite 0,X Hard(X/1024),Y Hard(Y/1024)-YS,1
- YS=Min(Max(Y/1024-128,0),Screen Height-256)
- Screen Offset 0,0,YS
-
- If Mouse Key=1 and XSP/100=0 and YSP/100=0
- If Point(X/1024,Y/1024+9)>0
- Add XSP,Rnd(4)*256-512 : Add YSP,-Rnd(2)*512-512
- Screen Offset 0,0,YS+3+Rnd(3)
- End If
- End If
-
- Wait Vbl
-
- Until Y/1024>Screen Height
-
- Loop